package com.lqq.designPattern.behavioral_pattern.iterator;

//测试类
public class Client {
    public static void main(String[] args) {
        //创建聚合对象
        StudentAggregate aggregate = new StudentAggregateImpl();
        //向聚合对象中添加元素
        aggregate.addStudent(new Student("001", "张无忌"));
        aggregate.addStudent(new Student("002", "赵敏"));
        aggregate.addStudent(new Student("003", "周芷若"));
        aggregate.addStudent(new Student("004", "卢本伟"));
        //遍历聚合对象
        //1.获取迭代器对象
        StudentIterator it = aggregate.getStudentIterator();
        //2.遍历迭代器
        while (it.hasNext()) {
            //获取元素
            Student student = it.next();
            System.out.println(student);
        }
    }
}
